/*
*
==============================================================================
*  Name        : 
*  Part of     : Omen Game Engine
*  Description : 
*  Version     : 1.0
*
*  Copyright (c) 2013 Lauri Kortevaara.
* 
==============================================================================
*/

#define OMEN_SOURCE

#include <IOmenObject.h>

using namespace Omen;

#include <iostream>

///
/// <summary>Construct a new Omen::Object</summary>
///
IObject::IObject( Omen::IObject* pParent ) :
    m_pParent(pParent),
    m_objectId( newUUID() )
{
    //std::cout << "Omen::IObject:: new Object:" << std::endl << "\tOBJECT_ID:" << objectId().Data << std::endl;
}

IObject::~IObject()
{
    //std::cout << "Omen::IObject:: deleted Object:" << std::endl << "\tOBJECT_ID:" << objectId().Data << std::endl;
}

Omen_GUID IObject::objectId() const                   /// <summary>Return object ID of scene</summary>
{
    return m_objectId;
}

///
/// <summary>Returns the parent Object</summary>
///
Omen::IObject* const& IObject::parent() const
{
    return m_pParent;
}

///
/// <summary>Sets the parent Object</summary>
///
void IObject::setParent( Omen::IObject* const& pParent )
{
    m_pParent = pParent;
}

///
/// <summary>Sets a new property to the object</summary>
///
void IObject::setProperty( const std::wstring& propertyName, const std::wstring& propertyValue )
{
    m_properties[propertyName] = propertyValue;
}

///
/// <summary>Gets a property value from the object</summary>
///
bool IObject::getProperty( const std::wstring& propertyName, std::wstring& propertyValue )
{
    bool bSuccess = false;

    if( m_properties.find(propertyName) != m_properties.end() )
    {
        propertyValue = m_properties[propertyName];
        bSuccess = true;
    }
    
    return bSuccess;
}

/// <summary>Returns true if this object acts as a dynamic physical object, false if it's just static</summary>
bool IObject::isDynamic() const
{
    return false;
}

/// <summary>Sets this object as a dynamic physical object which can move around the scene using physical laws</summary>
void IObject::setDynamic()
{

}

std::wstring IObject::name() const
{
    std::wstring name;
    if( m_properties.find(L"name") != m_properties.end() )
        name = m_properties.find(L"name")->second;
    return name;
}